package com.google.jayd.app;

import java.awt.EventQueue;
import java.io.IOException;
import java.util.HashMap;
import java.util.Properties;

import javax.swing.JFrame;

import com.google.jayd.core.YouTubeAPIWrapper;

public class JaydApp {

	private static final String PROP_KEY_AUTH = "authKey";
	private static final String JAYD_PROPERTIES = "/res/appData/jayd.properties";

	private JFrame frame;
	private Properties properties;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JaydApp window = new JaydApp();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 * 
	 * @throws IOException
	 */
	public JaydApp() throws IOException {
		loadAppData();
		initialize();
	}

	private void loadAppData() throws IOException {
		properties = new Properties();
		properties.load(this.getClass().getResourceAsStream(JAYD_PROPERTIES));
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		YouTubeAPIWrapper wr = new YouTubeAPIWrapper(
				properties.getProperty(PROP_KEY_AUTH));
		wr.videos.list.getJSONObject(new HashMap<String, String>());

		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

}
